package com.codeduck.business.controller;

import com.alibaba.fastjson.JSON;
import com.codeduck.business.domain.BusinessBO;
import com.codeduck.business.domain.BusinessRes;
import com.codeduck.business.service.IBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @createDate: 2022-08-20
 */
@RestController
@Slf4j
public class BusinessController {
    @Resource
    private IBusinessService businessService;

    @PostMapping("business/buy")
    public Object handleBusiness(@RequestBody BusinessBO businessBO) {
        BusinessRes businessRes = businessService.handleBusiness(businessBO);
        Assert.notNull(businessRes, "服务响应异常");
        log.info("购买信息：[{}]", JSON.toJSONString(businessRes));
        return businessRes;
    }
}
